#!/usr/bin/env bash

# The `external_` database settings only apply when terraform is called with create_mysql_db: true
exec jq '{
  "project_id": .project_id,
  "zone": .zone,
  "preemptible": true,
  "tags": ["bosh-director"],
  "director_name": "director",
  "internal_cidr": .internal_cidr,
  "internal_ip": .director_ip,
  "external_ip": .director_public_ip,
  "internal_gw": .gateway,
  "network":    .network,
  "subnetwork": .subnetwork,
  "reserved_range": [.gateway, .director_ip],
  "gcp_credentials_json": $ENV.GCP_JSON_KEY,
  "external_db_host": .mysql_host,
  "external_db_port": 3306,
  "external_db_user": .mysql_user,
  "external_db_password": .mysql_password,
  "external_db_adapter": "mysql2",
  "external_db_name": "bosh"
}' \
  < environment/metadata
